home *** CD-ROM | disk | FTP | other *** search
- Path: news.applink.net!haskett
- From: haskett@news.applink.net (Brian Haskett)
- Newsgroups: comp.lang.c++
- Subject: reference counting (and inheritance)
- Date: 7 Mar 1996 15:20:25 GMT
- Organization: AppLink Corp.
- Sender: haskett@applink.net
- Message-ID: <4hmurp$rs4@news2.nkn.net>
- NNTP-Posting-Host: applink.applink.net
-
- I am attempting to implement reference counting classes that allow me
- to have "smart" pointers to database objects. The reference classes
- keep a counter in the db object of how many references are currently
- pointing to that object, and when the count reaches zero, the object is
- deleted from the heap with the "delete" operator.
-
- The problem is that the reference class template that I created does not
- follow the same conversion rules as standard pointer conversions.
- ARM r.4.6 describes that "A pointer to a class may be converted to
- a pointer to an accessible base class of that class." I need that
- kind of behavior with my reference class.
-
- I have the following example that demonstrates the problem:
-
- template <class T>
- class JtsRefT
- {
- private:
- T *ptr;
-
- public:
- JtsRefT (T *t=NULL) : ptr(t) { if (t!=NULL) t->IncRefCount(); }
- ~JtsRefT () { if (ptr!=NULL && ptr->DecRefCount()==0) delete ptr; }
-
- operator T* () const { return ptr; }
-
- const T* operator-> () const { return ptr; }
- T* operator-> () { return ptr; }
-
- const T& operator* () const { return *ptr; }
- T& operator* () { return *ptr; }
- };
-
- class A
- {
- private:
- long refCount;
-
- public:
- long IncRefCount () { return ++refCount; }
- long DecRefCount () { return --refCount; }
- };
-
- typedef JtsRefT<A> AREF;
-
- class B : public A
- {
- };
-
- typedef JtsRefT<B> BREF;
-
- main ()
- {
- BREF bref;
- AREF aref=bref;
-
- return 0;
- };
-
-
- When compiling on AIX 3.2.5, I correctly get the following error:
- "test66.C", line 43.19: 1540-228: (S) No suitable constructor or conversion
- function exists for conversion from "BREF" to "JtsRefT<A>".
- make: 1254-004 The error code from the last command is 1.
-
- How can I modify my implementation to follow the standard pointer
- conversion ?
-
- -thanks
- Brian Haskett
- haskett@vnet.ibm.com
- haskett@applink.net
- Newsgroups: comp.lang.c++
- Subject: Reference Counting (and Inheritance)
- Summary:
- Expires:
- Sender: haskett@applink.net
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- Newsgroups: comp.lang.c++
- Subject: Reference Counting Pointers to Objects
- Summary:
- Expires:
- Sender: haskett@applink.net
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- I am attempting to implement reference counting classes that allow me
- to have "smart" pointers to database objects. The reference classes
- keep a counter in the db object of how many references are currently
- pointing to that object, and when the count reaches zero, the object is
- deleted from the heap with the "delete" operator.
-
- The problem is that the reference class template that I created does not
- follow the same conversion rules as standard pointer conversions.
- ARM r.4.6 describes that "A pointer to a class may be converted to
- a pointer to an accessible base class of that class." I need that
- kind of behavior with my reference class.
-
- I have the following example that demonstrates the problem:
-
- template <class T>
- class JtsRefT
- {
- private:
- T *ptr;
-
- public:
- JtsRefT (T *t=NULL) : ptr(t) { if (t!=NULL) t->IncRefCount(); }
- ~JtsRefT () { if (ptr!=NULL && ptr->DecRefCount()==0) delete ptr; }
-
- operator T* () const { return ptr; }
-
- const T* operator-> () const { return ptr; }
- T* operator-> () { return ptr; }
-
- const T& operator* () const { return *ptr; }
- T& operator* () { return *ptr; }
- };
-
- class A
- {
- private:
- long refCount;
-
- public:
- long IncRefCount () { return ++refCount; }
- long DecRefCount () { return --refCount; }
- };
-
- typedef JtsRefT<A> AREF;
-
- class B : public A
- {
- };
-
- typedef JtsRefT<B> BREF;
-
- main ()
- {
- BREF bref;
- AREF aref=bref;
-
- return 0;
- };
-
-
- When compiling on AIX 3.2.5, I correctly get the following error:
- "test66.C", line 43.19: 1540-228: (S) No suitable constructor or conversion
- function exists for conversion from "BREF" to "JtsRefT<A>".
- make: 1254-004 The error code from the last command is 1.
-
- How can I modify my implementation to follow the standard pointer
- conversion ?
-
- -thanks
- Brian Haskett
- haskett@vnet.ibm.com
- haskett@applink.net
- Newsgroups: comp.lang.c++
- Subject: Reference Counting (inheritance)
- Summary:
- Expires:
- Sender:
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- Newsgroups: comp.lang.c++
- Subject: Reference Counting Pointers to Objects
- Summary:
- Expires:
- Sender: haskett@applink.net
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- I am attempting to implement reference counting classes that allow me
- to have "smart" pointers to database objects. The reference classes
- keep a counter in the db object of how many references are currently
- pointing to that object, and when the count reaches zero, the object is
- deleted from the heap with the "delete" operator.
-
- The problem is that the reference class template that I created does not
- follow the same conversion rules as standard pointer conversions.
- ARM r.4.6 describes that "A pointer to a class may be converted to
- a pointer to an accessible base class of that class." I need that
- kind of behavior with my reference class.
-
- I have the following example that demonstrates the problem:
-
- template <class T>
- class JtsRefT
- {
- private:
- T *ptr;
-
- public:
- JtsRefT (T *t=NULL) : ptr(t) { if (t!=NULL) t->IncRefCount(); }
- ~JtsRefT () { if (ptr!=NULL && ptr->DecRefCount()==0) delete ptr; }
-
- operator T* () const { return ptr; }
-
- const T* operator-> () const { return ptr; }
- T* operator-> () { return ptr; }
-
- const T& operator* () const { return *ptr; }
- T& operator* () { return *ptr; }
- };
-
- class A
- {
- private:
- long refCount;
-
- public:
- long IncRefCount () { return ++refCount; }
- long DecRefCount () { return --refCount; }
- };
-
- typedef JtsRefT<A> AREF;
-
- class B : public A
- {
- };
-
- typedef JtsRefT<B> BREF;
-
- main ()
- {
- BREF bref;
- AREF aref=bref;
-
- return 0;
- };
-
-
- When compiling on AIX 3.2.5, I correctly get the following error:
- "test66.C", line 43.19: 1540-228: (S) No suitable constructor or conversion
- function exists for conversion from "BREF" to "JtsRefT<A>".
- make: 1254-004 The error code from the last command is 1.
-
- How can I modify my implementation to follow the standard pointer
- conversion ?
-
- -thanks
- Brian Haskett
- haskett@vnet.ibm.com
- haskett@applink.net
- Newsgroups: comp.lang.c++
- Subject: Reference Counting (and Inheritance)
- Summary:
- Expires:
- Sender: haskett@applink.net
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- Newsgroups: comp.lang.c++
- Subject: Reference Counting Pointers to Objects
- Summary:
- Expires:
- Sender: haskett@applink.net
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- I am attempting to implement reference counting classes that allow me
- to have "smart" pointers to database objects. The reference classes
- keep a counter in the db object of how many references are currently
- pointing to that object, and when the count reaches zero, the object is
- deleted from the heap with the "delete" operator.
-
- The problem is that the reference class template that I created does not
- follow the same conversion rules as standard pointer conversions.
- ARM r.4.6 describes that "A pointer to a class may be converted to
- a pointer to an accessible base class of that class." I need that
- kind of behavior with my reference class.
-
- I have the following example that demonstrates the problem:
-
- template <class T>
- class JtsRefT
- {
- private:
- T *ptr;
-
- public:
- JtsRefT (T *t=NULL) : ptr(t) { if (t!=NULL) t->IncRefCount(); }
- ~JtsRefT () { if (ptr!=NULL && ptr->DecRefCount()==0) delete ptr; }
-
- operator T* () const { return ptr; }
-
- const T* operator-> () const { return ptr; }
- T* operator-> () { return ptr; }
-
- const T& operator* () const { return *ptr; }
- T& operator* () { return *ptr; }
- };
-
- class A
- {
- private:
- long refCount;
-
- public:
- long IncRefCount () { return ++refCount; }
- long DecRefCount () { return --refCount; }
- };
-
- typedef JtsRefT<A> AREF;
-
- class B : public A
- {
- };
-
- typedef JtsRefT<B> BREF;
-
- main ()
- {
- BREF bref;
- AREF aref=bref;
-
- return 0;
- };
-
-
- When compiling on AIX 3.2.5, I correctly get the following error:
- "test66.C", line 43.19: 1540-228: (S) No suitable constructor or conversion
- function exists for conversion from "BREF" to "JtsRefT<A>".
- make: 1254-004 The error code from the last command is 1.
-
- How can I modify my implementation to follow the standard pointer
- conversion ?
-
- -thanks
- Brian Haskett
- haskett@vnet.ibm.com
- haskett@applink.net
- Newsgroups: comp.lang.c++
- Subject:
- Summary:
- Expires:
- Sender:
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
-
- Newsgroups: comp.lang.c++
- Subject: reference counting (inheritance)
- Summary:
- Expires:
- Sender:
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- I am attempting to implement reference counting classes that allow me
- to have "smart" pointers to database objects. The reference classes
- keep a counter in the db object of how many references are currently
- pointing to that object, and when the count reaches zero, the object is
- deleted from the heap with the "delete" operator.
-
- The problem is that the reference class template that I created does not
- follow the same conversion rules as standard pointer conversions.
- ARM r.4.6 describes that "A pointer to a class may be converted to
- a pointer to an accessible base class of that class." I need that
- kind of behavior with my reference class.
-
- I have the following example that demonstrates the problem:
-
- template <class T>
- class JtsRefT
- {
- private:
- T *ptr;
-
- public:
- JtsRefT (T *t=NULL) : ptr(t) { if (t!=NULL) t->IncRefCount(); }
- ~JtsRefT () { if (ptr!=NULL && ptr->DecRefCount()==0) delete ptr; }
-
- operator T* () const { return ptr; }
-
- const T* operator-> () const { return ptr; }
- T* operator-> () { return ptr; }
-
- const T& operator* () const { return *ptr; }
- T& operator* () { return *ptr; }
- };
-
- class A
- {
- private:
- long refCount;
-
- public:
- long IncRefCount () { return ++refCount; }
- long DecRefCount () { return --refCount; }
- };
-
- typedef JtsRefT<A> AREF;
-
- class B : public A
- {
- };
-
- typedef JtsRefT<B> BREF;
-
- main ()
- {
- BREF bref;
- AREF aref=bref;
-
- return 0;
- };
-
-
- When compiling on AIX 3.2.5, I correctly get the following error:
- "test66.C", line 43.19: 1540-228: (S) No suitable constructor or conversion
- function exists for conversion from "BREF" to "JtsRefT<A>".
- make: 1254-004 The error code from the last command is 1.
-
- How can I modify my implementation to follow the standard pointer
- conversion ?
-
- -thanks
- Brian Haskett
- haskett@vnet.ibm.com
- haskett@applink.net
- Newsgroups: comp.lang.c++
- Subject: Reference Counting (and Inheritance)
- Summary:
- Expires:
- Sender: haskett@applink.net
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- Newsgroups: comp.lang.c++
- Subject: Reference Counting Pointers to Objects
- Summary:
- Expires:
- Sender: haskett@applink.net
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- I am attempting to implement reference counting classes that allow me
- to have "smart" pointers to database objects. The reference classes
- keep a counter in the db object of how many references are currently
- pointing to that object, and when the count reaches zero, the object is
- deleted from the heap with the "delete" operator.
-
- The problem is that the reference class template that I created does not
- follow the same conversion rules as standard pointer conversions.
- ARM r.4.6 describes that "A pointer to a class may be converted to
- a pointer to an accessible base class of that class." I need that
- kind of behavior with my reference class.
-
- I have the following example that demonstrates the problem:
-
- template <class T>
- class JtsRefT
- {
- private:
- T *ptr;
-
- public:
- JtsRefT (T *t=NULL) : ptr(t) { if (t!=NULL) t->IncRefCount(); }
- ~JtsRefT () { if (ptr!=NULL && ptr->DecRefCount()==0) delete ptr; }
-
- operator T* () const { return ptr; }
-
- const T* operator-> () const { return ptr; }
- T* operator-> () { return ptr; }
-
- const T& operator* () const { return *ptr; }
- T& operator* () { return *ptr; }
- };
-
- class A
- {
- private:
- long refCount;
-
- public:
- long IncRefCount () { return ++refCount; }
- long DecRefCount () { return --refCount; }
- };
-
- typedef JtsRefT<A> AREF;
-
- class B : public A
- {
- };
-
- typedef JtsRefT<B> BREF;
-
- main ()
- {
- BREF bref;
- AREF aref=bref;
-
- return 0;
- };
-
-
- When compiling on AIX 3.2.5, I correctly get the following error:
- "test66.C", line 43.19: 1540-228: (S) No suitable constructor or conversion
- function exists for conversion from "BREF" to "JtsRefT<A>".
- make: 1254-004 The error code from the last command is 1.
-
- How can I modify my implementation to follow the standard pointer
- conversion ?
-
- -thanks
- Brian Haskett
- haskett@vnet.ibm.com
- haskett@applink.net
- Newsgroups: comp.lang.c++
- Subject: Reference Counting (inheritance)
- Summary:
- Expires:
- Sender:
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- Newsgroups: comp.lang.c++
- Subject: Reference Counting Pointers to Objects
- Summary:
- Expires:
- Sender: haskett@applink.net
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- I am attempting to implement reference counting classes that allow me
- to have "smart" pointers to database objects. The reference classes
- keep a counter in the db object of how many references are currently
- pointing to that object, and when the count reaches zero, the object is
- deleted from the heap with the "delete" operator.
-
- The problem is that the reference class template that I created does not
- follow the same conversion rules as standard pointer conversions.
- ARM r.4.6 describes that "A pointer to a class may be converted to
- a pointer to an accessible base class of that class." I need that
- kind of behavior with my reference class.
-
- I have the following example that demonstrates the problem:
-
- template <class T>
- class JtsRefT
- {
- private:
- T *ptr;
-
- public:
- JtsRefT (T *t=NULL) : ptr(t) { if (t!=NULL) t->IncRefCount(); }
- ~JtsRefT () { if (ptr!=NULL && ptr->DecRefCount()==0) delete ptr; }
-
- operator T* () const { return ptr; }
-
- const T* operator-> () const { return ptr; }
- T* operator-> () { return ptr; }
-
- const T& operator* () const { return *ptr; }
- T& operator* () { return *ptr; }
- };
-
- class A
- {
- private:
- long refCount;
-
- public:
- long IncRefCount () { return ++refCount; }
- long DecRefCount () { return --refCount; }
- };
-
- typedef JtsRefT<A> AREF;
-
- class B : public A
- {
- };
-
- typedef JtsRefT<B> BREF;
-
- main ()
- {
- BREF bref;
- AREF aref=bref;
-
- return 0;
- };
-
-
- When compiling on AIX 3.2.5, I correctly get the following error:
- "test66.C", line 43.19: 1540-228: (S) No suitable constructor or conversion
- function exists for conversion from "BREF" to "JtsRefT<A>".
- make: 1254-004 The error code from the last command is 1.
-
- How can I modify my implementation to follow the standard pointer
- conversion ?
-
- -thanks
- Brian Haskett
- haskett@vnet.ibm.com
- haskett@applink.net
- Newsgroups: comp.lang.c++
- Subject: Reference Counting (and Inheritance)
- Summary:
- Expires:
- Sender: haskett@applink.net
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- Newsgroups: comp.lang.c++
- Subject: Reference Counting Pointers to Objects
- Summary:
- Expires:
- Sender: haskett@applink.net
- Followup-To:
- Distribution:
- Organization: AppLink Corp.
- Keywords:
-
- I am attempting to implement reference counting classes that allow me
- to have "smart" pointers to database objects. The reference classes
- keep a counter in the db object of how many references are currently
- pointing to that object, and when the count reaches zero, the object is
- deleted from the heap with the "delete" operator.
-
- The problem is that the reference class template that I created does not
- follow the same conversion rules as standard pointer conversions.
- ARM r.4.6 describes that "A pointer to a class may be converted to
- a pointer to an accessible base class of that class." I need that
- kind of behavior with my reference class.
-
- I have the following example that demonstrates the problem:
-
- template <class T>
- class JtsRefT
- {
- private:
- T *ptr;
-
- public:
- JtsRefT (T *t=NULL) : ptr(t) { if (t!=NULL) t->IncRefCount(); }
- ~JtsRefT () { if (ptr!=NULL && ptr->DecRefCount()==0) delete ptr; }
-
- operator T* () const { return ptr; }
-
- const T* operator-> () const { return ptr; }
- T* operator-> () { return ptr; }
-
- const T& operator* () const { return *ptr; }
- T& operator* () { return *ptr; }
- };
-
- class A
- {
- private:
- long refCount;
-
- public:
- long IncRefCount () { return ++refCount; }
- long DecRefCount () { return --refCount; }
- };
-
- typedef JtsRefT<A> AREF;
-
- class B : public A
- {
- };
-
- typedef JtsRefT<B> BREF;
-
- main ()
- {
- BREF bref;
- AREF aref=bref;
-
- return 0;
- };
-
-
- When compiling on AIX 3.2.5, I correctly get the following error:
- "test66.C", line 43.19: 1540-228: (S) No suitable constructor or conversion
- function exists for conversion from "BREF" to "JtsRefT<A>".
- make: 1254-004 The error code from the last command is 1.
-
- How can I modify my implementation to follow the standard pointer
- conversion ?
-
- -thanks
- Brian Haskett
- haskett@vnet.ibm.com
- haskett@applink.net
-